package com.ruoyi.admin.service.impl;

import com.ruoyi.admin.mapper.RewardMapper;
import com.ruoyi.admin.service.IRewardService;
import com.ruoyi.common.core.domain.entity.Reward;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 奖品录入Service业务层处理
 * 
 * @author xukai
 * @date 2024-12-22
 */
@Service
public class RewardServiceImpl implements IRewardService 
{
    @Autowired
    private RewardMapper rewardMapper;

    /**
     * 查询奖品录入
     * 
     * @param id 奖品录入主键
     * @return 奖品录入
     */
    @Override
    public Reward selectRewardById(Long id)
    {
        return rewardMapper.selectRewardById(id);
    }

    /**
     * 查询奖品录入列表
     * 
     * @param reward 奖品录入
     * @return 奖品录入
     */
    @Override
    public List<Reward> selectRewardList(Reward reward)
    {
        return rewardMapper.selectRewardList(reward);
    }

    /**
     * 新增奖品录入
     * 
     * @param reward 奖品录入
     * @return 结果
     */
    @Override
    public int insertReward(Reward reward)
    {
        reward.setIsDeleted(false);
        reward.setRemain(reward.getAmount());
        reward.setCreatedAt(new Date());
        reward.setUpdatedAt(new Date());
        return rewardMapper.insertReward(reward);
    }

    /**
     * 修改奖品录入
     * 
     * @param reward 奖品录入
     * @return 结果
     */
    @Override
    public int updateReward(Reward reward)
    {
        return rewardMapper.updateReward(reward);
    }

    /**
     * 批量删除奖品录入
     * 
     * @param ids 需要删除的奖品录入主键
     * @return 结果
     */
    @Override
    public int deleteRewardByIds(Long[] ids)
    {
        return rewardMapper.deleteRewardByIds(ids);
    }

    /**
     * 删除奖品录入信息
     * 
     * @param id 奖品录入主键
     * @return 结果
     */
    @Override
    public int deleteRewardById(Long id)
    {
        return rewardMapper.deleteRewardById(id);
    }
}
